package com.bys.security;

import com.bys.response.Result;
import com.bys.response.ReultCode;
import com.bys.util.RespUtils;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 权限不足的, 使用方法级的注解会 进入这个方法
 */
public class AccessHandler implements AccessDeniedHandler {
    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {
        RespUtils.sendData(response, Result.fail(ReultCode.AUTH_ERR));
    }
}
